clear; clc;
addpath(fullfile(pwd, '..', 'lib'));
dataName ={ 'bbcnewssport_737n_1000d_5c_uni_12k','RELATHE_1427n_4322d_2c_tfidf_uni_12k',...
    'warpPIE10P_210n_2420d_10c_12k','COIL20_1440n_1024d_20c_uni_12k',...
    'UMIST_575n_644d_20c_12k','BASEHOCK_1993n_4862d_2c_tfidf_uni_12k',...
     'leukemia_72n_7070d_2c_12k','ALLAML_72n_7129d_2c_12k',...   
};
indicator={'acc_amkkc_res','nmi_amkkc_res','purity_amkkc_res'}  
for i1 =1:length(dataName)
    load(fullfile(pwd, '..', 'data', dataName{i1}));
    load(fullfile(pwd, '..', 'amkkc_res.mat'));
    ks = [5];
    Ks2 = zeros(size(Ks));
    for i2 = 1:size(Ks,3)
        Ktmp = knorm(Ks(:,:,i2));
        if max(Ktmp(:)) > 1
            Ktmp = Ktmp  / max(Ktmp(:));
        end
        Ks2(:,:,i2) = Ktmp;
    end
    clear Ks;
    for ind=3
    s=eval([indicator{ind}]);
    lambdas =s(i1,1);
    nRepeat = 1;
    [res_amkkc_re] = AMKKC_single_dataset(Ks2, Y, lambdas,ks,nRepeat);
    res_amkkc=res_amkkc_re(:,ind);
    res_amkkc
    mean(res_amkkc)
    save([dataName{i1},'_', indicator{ind},'_.mat'], 'res_amkkc');
    save(['..\','metricresult\',dataName{i1},'_', indicator{ind},'_.mat'], 'res_amkkc');
    end
end